package com.smarthouse.controller;

import com.smarthouse.model.ApiResponse;
import com.smarthouse.model.SmartHomeStatus;
import com.smarthouse.service.SmartHomeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

@Tag(name = "智能家居控制接口")
@RestController
@RequestMapping("/smarthome")
public class SmartHomeController {

    private final SmartHomeService smartHomeService;

    public SmartHomeController(SmartHomeService smartHomeService) {
        this.smartHomeService = smartHomeService;
    }

    @Operation(summary = "获取智能家居状态")
    @GetMapping("/status")
    public ApiResponse<SmartHomeStatus> getStatus() {
        return ApiResponse.success(smartHomeService.getStatus());
    }

    @Operation(summary = "切换锁状态")
    @PostMapping("/toggle-lock")
    public ApiResponse<Void> toggleLock() {
        smartHomeService.toggleLock();
        return ApiResponse.success(null);
    }

    @Operation(summary = "更新节能状态")
    @PostMapping("/update-energy-saving")
    public ApiResponse<Void> updateEnergySaving(@RequestParam boolean energySaving) {
        smartHomeService.updateEnergySaving(energySaving);
        return ApiResponse.success(null);
    }

    @Operation(summary = "更新温馨提醒")
    @PostMapping("/update-reminder")
    public ApiResponse<Void> updateReminder(@RequestParam String reminder) {
        smartHomeService.updateReminder(reminder);
        return ApiResponse.success(null);
    }
} 